<%--
  Created by IntelliJ IDEA.
  User: HW
  Date: 2024/12/19
  Time: 下午7:38
  To change this template use File | Settings | File Templates.
--%>
<%@ page language="java" contentType="text/html; charset=utf-8"
         pageEncoding="utf-8" %>
<%@ page import="java.sql.*" %>
<%@ page import="com.data.ConnData" %>
<%
    request.setCharacterEncoding("utf-8");
    String username = request.getParameter("username");
    String email = request.getParameter("email");
    String password2 = request.getParameter("password2");


    ConnData objdata = new ConnData();
    try {
        Connection hello=objdata.getConn();
    } catch (Exception e) {
        throw new RuntimeException(e);
    }
    String sql = "insert into user_table(nickname,email,password)  values(?,?,?)";
    PreparedStatement psmt = objdata.getPsmt(sql);
    try {
        psmt.setString(1, username);
        psmt.setString(2, email);
        psmt.setString(3, password2);
        int rs = psmt.executeUpdate();
        if (rs>=1) {
                response.sendRedirect("login.jsp");
        } else {
%>
注册不成功<br />
<a href="login.jsp">重新登录</a>
<%
    }
    psmt.close();
    objdata.close();
} catch (SQLException e) {
    e.printStackTrace();
%>
数据库操作出现错误，请稍后再试！
<%
    }
%>